﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExcelGenerator.SpreadSheet
{
    public class Column
    {
        private int _Width;
        private Boolean _AutoFitWidth;

        /// <summary>
        /// Create a new column
        /// </summary>
        public Column()
        {
            _AutoFitWidth = false;
            _Width = 0;
        }

        /// <summary>
        /// Create a new column
        /// </summary>
        /// <param name="width">
        /// Specifies the width to apply in this column
        /// </param>
        public Column(int width)
        {
            _AutoFitWidth = false;
            _Width = width;
        }

        /// <summary>
        /// Create a new column
        /// </summary>
        /// <param name="width">
        /// Specifies the width to apply in this column
        /// </param>
        /// <param name="autofit">
        /// Specifies if this column should be autosized, only date and number values are autofitted.
        /// </param>
        public Column(int width, Boolean autofit)
        {
            _AutoFitWidth = autofit;
            _Width = width;
        }

        /// <summary>
        /// Specifies the width to apply in this column
        /// </summary>
        public int Width
        {
            get
            {
                return _Width;
            }
            set
            {
                if (value <= 0)
                {
                    _Width = 0;
                }
                else
                {
                    _Width = value;
                }
            }
        }

        /// <summary>
        /// If this attribute is specified as True, it means that this column should be autosized for numeric and date values only. We do not autofit textual values.
        /// If both Width and AutoFitWidth exist, the behavior is as follows:
        /// AutoFitWidth=True and Width is unspecified: Autofit the column width to fit the content.
        /// AutoFitWidth=True and Width is specified: Set the column to the specified width and only autofit if the size of the content is larger than the specified width.
        /// AutoFitWidth=False and Width is unspecified: Use the default column width.
        /// AutoFitWidth=False and Width is specified: Use the specified width.
        /// Default value is False
        /// </summary>
        public Boolean AutoFitWidth
        {
            get
            {
                return _AutoFitWidth;
            }
            set
            {
                _AutoFitWidth = value;               
            }
        }
    }
}
